<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class UserController extends Controller
{
    //
    public function index()
    {
        $user = User::all();
        // // $user = DB::table('users')->get(['name', 'email']);
        // // $arr = $user->toArray();
        // // $env = getcwd();
        // $env = auth()->guard();
        // dump($env);
        // exit;
        // $arr = [];
        // foreach ($this->one_to_three() as $key => $value) {
        //     $arr[] = $value;
        // }
        return response()->json($user);
    }
    private function one_to_three()
    {
        for ($i = 0; $i < 100; $i++) {
            yield $i . "asddddddddddddddddddddddddddddddddddddddddd";
        }
    }

    public function show($id)
    {
        $user = User::find($id);
        return response()->json($user);
    }

    public function create()
    {
        return 'create user';
    }

    public function store(Request $request)
    {
        //
        return 'user stored';
    }

    public function edit($id)
    {
        //
        return 'user' . $id;
    }

    public function update(Request $request, $id)
    {
        //
        return 'user' . $id . ' updated';
    }

    public function destroy($id)
    {
        //
        return 'user' . $id . ' deleted';
    }

    public function profile()
    {
        return 'profile';
    }
}
